#!/bin/bash
ERRORS=$(grep -i "error" /var/log/syslog | tail -n 5)
if [ -n "$ERRORS" ]; then
  echo "Recent errors in syslog:\n$ERRORS" | mail -s "Error Log Alert" admin@example.com
fi
